function analyzeGrades(scores) {
    // 1. 输入验证
    if (!Array.isArray(scores)) {
        throw new Error('输入必须是一个数组');
    }
    
    if (scores.length === 0) {
        throw new Error('成绩数组不能为空');
    }
    
    for (let i = 0; i < scores.length; i++) {
        const score = scores[i];
        if (typeof score !== 'number' || isNaN(score)) {
            throw new Error(`第${i + 1}个成绩不是有效数字`);
        }
        if (score < 0 || score > 100) {
            throw new Error(`第${i + 1}个成绩超出有效范围(0-100)`);
        }
    }

    const total = scores.length;
    
    // 2. 计算平均分
    let sum = 0;
    for (let i = 0; i < total; i++) {
        sum += scores[i];
    }
    const average = parseFloat((sum / total).toFixed(2));

    // 3. 寻找最高分和最低分
    let max = scores[0];
    let min = scores[0];
    for (let i = 1; i < total; i++) {
        if (scores[i] > max) max = scores[i];
        if (scores[i] < min) min = scores[i];
    }

    // 4. 统计及格率
    let passCount = 0;
    for (let i = 0; i < total; i++) {
        if (scores[i] >= 60) passCount++;
    }
    const passRate = ((passCount / total) * 100).toFixed(2) + '%';

    // 5. 统计分布
    const distributionRanges = [
        { range: '90-100', min: 90, max: 100 },
        { range: '80-89', min: 80, max: 89 },
        { range: '70-79', min: 70, max: 79 },
        { range: '60-69', min: 60, max: 69 },
        { range: '0-59', min: 0, max: 59 }
    ];

    const distribution = {};
    
    // 初始化分布对象
    distributionRanges.forEach(item => {
        distribution[item.range] = { count: 0, percentage: '0.00%' };
    });

    // 统计每个分数段的人数
    for (let i = 0; i < total; i++) {
        const score = scores[i];
        for (const range of distributionRanges) {
            if (score >= range.min && score <= range.max) {
                distribution[range.range].count++;
                break;
            }
        }
    }

    // 计算百分比
    for (const range in distribution) {
        const count = distribution[range].count;
        const percentage = ((count / total) * 100).toFixed(2) + '%';
        distribution[range].percentage = percentage;
    }

    // 6. 返回结果
    return {
        total: total,
        average: average,
        max: max,
        min: min,
        passRate: passRate,
        distribution: distribution
    };
}

// 使用提供的测试代码
const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

rl.on('line', (input) => {
    try {
        // 解析输入，处理可能的空格和逗号分隔
        let scoresArray;
        if (input.includes(',')) {
            scoresArray = input.split(',').map(item => {
                const num = parseFloat(item.trim());
                if (isNaN(num)) throw new Error('输入包含非数字字符');
                return num;
            });
        } else if (input.includes(' ')) {
            scoresArray = input.split(' ').map(item => {
                const num = parseFloat(item.trim());
                if (isNaN(num)) throw new Error('输入包含非数字字符');
                return num;
            });
        } else {
            // 如果是单个数字或数组格式
            try {
                scoresArray = JSON.parse(input);
                if (!Array.isArray(scoresArray)) {
                    scoresArray = [parseFloat(input)];
                }
            } catch {
                scoresArray = [parseFloat(input)];
            }
        }
        
        const result = analyzeGrades(scoresArray);
        console.dir(result, { depth: null });
    } catch (error) {
        console.error(error.message);
    } finally {
        rl.close();
    }
});